﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Login : System.Web.UI.Page
{
    private DBClass _db = new DBClass();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Request.QueryString["status"]))
        {
            if (ToSQL.EmptyNull(Request.QueryString["status"]) == "logout")
            {
                Session["user"] = null;
            }
        }
        if (Session["user"] != null)
        {
            Response.Redirect("~/Default.aspx");
        }
    }
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        System.Data.DataRow rowUser = _db.web_sp_LoginWebsite(ToSQL.EmptyNull(txtUser.Text), ToSQL.EmptyNull(txtPass.Text));
        if (rowUser != null)
        {
            if (BaseView.GetBooleanFieldValue(rowUser, "isOk"))
            {
                Session["user"] = rowUser;
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                lbMessage.Visible = true;
            }
        }
    }
}